<template>
	<view></view>
</template>

<script>
	import store from '@/store'
	
	export default {
		data() {
		  return {
		    // 头像
		    avatar: 'https://dj.letosdk.com/uploads/20250401/c0c556c386819d0a169327cfb8f1b27f.png',
		    // 昵称
		    nickname: '测试昵称',
		    // 应用用户id
		    app_user_id: '5',
		    // appid
		    appid: '2f70faa78ee66b1919b8',
		    // 用户uuid
		    user_uuid: '2f70faa78ee66b1919b85',
			// 应用积分
			app_points: '100',
		  }
		},
		onLoad(options) {
			this.submitLogin(options);
		},
		methods: {
			// 确认登录
			submitLogin(options) {		
				const app = options

				store.dispatch('Login', {
						smsCode: app.appid,
						mobile: app.user_uuid,
						isParty: false,
						partyData: {},
						// 其他参数
						appid: app.appid,
						nickname: app.nickname,
						avatar: app.avatar,
						app_user_id: app.app_user_id,
						app_points: app.app_points,
						user_uuid: app.user_uuid,
						type: 3,//验证appid
					})
					.then(result => {
					   uni.setStorage({
					     key: 'appid',
					     data:app.appid
					   });
					   
					   this.$navTo('pages/index/index')
					})
					.catch(err => {
						app.disabled = false
						// 跳转回原页面
						if (err.result.data.isBack) {
							setTimeout(() => app.onNavigateBack(1), 2000)
						}
					})
					.finally(() => app.isLoading = false)
			},

			/**
			 * 登录成功-跳转回原页面
			 */
			onNavigateBack(delta = 1) {
				const pages = getCurrentPages()
				if (pages.length > 1) {
					uni.navigateBack({
						delta: Number(delta || 1)
					})
				} else {
					this.$navTo('pages/index/index')
				}
			}
		}
	}
	
</script>

<style>
</style>